package com.kylin.state;

//测试礼让线程，礼让不一定成功。看cpu调度心情
public class TestYield {

    public static void main(String[] args) {
        MyYield yield = new MyYield();

        new Thread(yield,"后裔").start();
        new Thread(yield,"嫦娥").start();
    }


}

class MyYield implements Runnable{


    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+"线程开始执行");
        Thread.yield();//线程礼让
        System.out.println(Thread.currentThread().getName()+"线程停止执行");
    }
}


